﻿namespace Steamworks
{
    using System;
    using System.Collections.Generic;
    using System.Runtime.CompilerServices;

    public static class SteamEventExtension
    {
        private static List<object> callResultCaches = new List<object>();

        public static void CreateCallResult<T>(this SteamAPICall_t call, Action<T, bool> func)
        {
            <CreateCallResult>c__AnonStorey6C<T> storeyc = new <CreateCallResult>c__AnonStorey6C<T> {
                func = func,
                callResult = new CallResult<T>(null)
            };
            storeyc.callResult.Set(call, new CallResult<T>.APIDispatchDelegate(storeyc.<>m__106));
            callResultCaches.Add(storeyc.callResult);
        }

        [CompilerGenerated]
        private sealed class <CreateCallResult>c__AnonStorey6C<T>
        {
            internal CallResult<T> callResult;
            internal Action<T, bool> func;

            internal void <>m__106(T v, bool f)
            {
                SteamEventExtension.callResultCaches.Remove(this.callResult);
                this.func(v, f);
            }
        }
    }
}

